﻿//using System.Text;

//namespace WXWorkSvc.Common.TagHelpers;

//[HtmlTargetElement("table-row", Attributes = "for*")]
//[HtmlTargetElement("table-row", Attributes = "td*")]
////[HtmlTargetElement("tr", TagStructure = TagStructure.WithoutEndTag)]
//public class TableRowTagHelper : TagHelper
//{
//    private readonly Dictionary<int, string> _TDs = new Dictionary<int, string>();
//    [HtmlAttributeName(DictionaryAttributePrefix = "td")]
//    public IDictionary<string, string> TDs { get; set; } = new Dictionary<string, string>();
//    [HtmlAttributeName(DictionaryAttributePrefix = "for")]
//    public IDictionary<string, ModelExpression> Fors { get; set; } = new Dictionary<string, ModelExpression>();

//    public override void Process(TagHelperContext context, TagHelperOutput output)
//    {
//        output.TagMode = TagMode.StartTagAndEndTag;

//        foreach (var item in Fors)
//            _TDs[int.Parse(item.Key)] = item.Value.Model?.ToString() ?? "";//.GetDisplayName();
//        foreach (var item in TDs)
//            _TDs[int.Parse(item.Key)] = item.Value;

//        StringBuilder sb = new StringBuilder();
//        sb.Append("<tr>");
//        sb.AppendLine(string.Join("", _TDs.OrderBy(ii => ii.Key).Select(ii => $"<td>{ii.Value}</td>")));
//        sb.Append("</tr>");
//        output.Content.SetHtmlContent(sb.ToString());
//    }
//}
